package mockito.cglibt1;

/**
 * @author      : yang.xp
 * @date        : 2021/10/12 16:43
 * @description : cglib 的学习https://www.iteye.com/blog/llying-220452
 */
public class Client {

    public static void main(String[] args) {
        TableDAO tableDao = TableDAOFactory.getInstance();
        doMethod(tableDao);
        System.out.println(" --- ");
        haveAuth();
        System.out.println(" --- ");
        haveNoAuth();
        System.out.println(" --- ");
        haveAuthByFilter();
    }

    public static void doMethod(TableDAO dao) {
        dao.create();
        dao.query();
        dao.update();
        dao.delete();
    }

    public static void haveAuth() {
        TableDAO tDao = TableDAOFactory.getAuthInstance(new AuthProxy("张三"));
        doMethod(tDao);
    }

    public static void haveNoAuth() {
        TableDAO tDao = TableDAOFactory.getAuthInstance(new AuthProxy("李四"));
        doMethod(tDao);
    }

    public static void haveAuthByFilter(){
        TableDAO tDao = TableDAOFactory.getAuthInstanceByFilter(new AuthProxy("张三"));
        doMethod(tDao);
        System.out.println();
        tDao = TableDAOFactory.getAuthInstanceByFilter(new AuthProxy("李四"));
        doMethod(tDao);
    }
}
